package com.david.reader.bean

import java.io.Serializable

class BookBean() : Serializable {
    constructor(bookName: String, type: Int) : this() {
        this.bookName = bookName
        this.type = type

        this.id = System.currentTimeMillis().toString() + Math.random().toLong()
    }

    constructor(bookName: String, type: Int, id:String) : this() {
        this.bookName = bookName
        this.type = type
        this.id = id
    }

    var bookName:String? = ""
    set(value) {
        field = value
        value?.let {
            if (it.contains(".")) {
                simpleName = it.substring(0, it.lastIndexOf("."))
            } else {
                simpleName = value
            }
        }
    }
    var simpleName:String? = ""//无格式后缀的名称

    var type: Int = 0//type：0 txt，1：pdf

    var id: String? =""

    var pageCount = 0
    var currentPage = 0

    override fun equals(other: Any?): Boolean {
        if (other == null) {
            return false
        }
        if (other !is BookBean) {
            return false
        }
        return id.equals(other.id) && bookName.equals(other.bookName) && type == other.type
    }
}